<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/bootstrap3/jsone/bootstrap.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script src="/res/third/layer/layer.js"></script>
<script type="text/javascript">
	function sosuo(){
		var lpath =location.pathname;
		//var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+1);
		$("#soform").submit();
	}

	$(document).ready(function(){
		$("#fathCheck").click(function(){
			$(".giftInfoIds").prop("checked",this.checked);
		})
	})
	
	function plexport(state){
			if(confirm("确认导出吗？")){
//				var ids="";
//		    	var len=$(".giftInfoIds:checked").length;
//		    	if(len==0){
//		    		alert("请选择要导出的元素");
//		    		return false;
//		    	}
//		    	$(".giftInfoIds:checked").each(function(index){
//		    		if(index!=(len-1)){
//		    			ids+=$(this).val()+",";
//					}else{
//						ids+=$(this).val();
//					}
//		    	})
		    	$("#exportids").val(state);
		    	$("#mainexport").submit();
			}
	}
	
	function changeGiftState(id,giftName,contactName,contactAdd,contactTel){
		layer.open({
			  type:1,
			  btn:['确认','取消'],
			  area: ['700px', '450px'],
			  title: '邮寄礼品',
			  content: $("#bckudiv"),
			  success: function(layero, index){
				 	$(layero).find("#giftname").text(giftName);
				 	$(layero).find("#contactName").text(contactName);
				 	$(layero).find("#contactAdd").text(contactAdd);
				 	$(layero).find("#contactTel").text(contactTel);
			
				  },
			  yes: function(index, layero){
				    var courierNum=$("#courierNum").val().trim();
				    var courierCompanyId=$("#courierCompanyId").val();
				 	if(courierNum==""){
				 		alert("请填写快递单号！")
				 	}else{
				 		art.dialog.post({
					  		  
				    		type : "post",
				    		dataType : "json",
				    		url : "/gift/setExchange.do",
				            data:{id:id,courierNum:courierNum,courierCompanyId:courierCompanyId},
				    		success : function(data) {
				    			 if(data.success){
				    				 location.reload();
				    			 }else{
				    				 alert(data.msg);
				    			 }
				    		}
				     
				    		},"数据正在提交.... ");
				 	}
				    layer.close(index); 
				  }
			});     
		
		
	}
</script>
<style type="text/css">
	table{table-layout: fixed;}
	td{overflow: hidden;text-overflow:ellipsis;}
	.excelbtn{display: inline-block;height: 100%;width: 100px;background-color:#38A4C7;color: #fff;text-align: center;line-height: 35px;cursor: pointer;border-radius:5px;}
	.bcksty{width: 700px; height: 300px; display: none;font-size: 13px;font-weight: bold;padding: 0px 12px;}
	.title_gift{text-align: left;padding-top: 30px;border-bottom: 1px solid #ddd;}
	.title_gift_text{display: inline-block;margin-left: 10px;border-bottom: 3px solid #E64545;font-size: 14px;width: 80px;text-align: center;}
	.title_info_font{}
	.jl_title {
	    width: 100%;
	    display: inline-block;
	    height: 38px;
	    border-top: 1px solid #ddd;
	    border-bottom: 1px solid #ddd;
	    background-color: #F5F5F5;
	 }
	.jl_title_text ,.jl_stock_text{
	    width: 50%;
	    display: inline-block;
	    float: left;
	    line-height: 38px;
	    text-align: center;
	}
	.jl_stock{
		width: 100%;
	    display: inline-block;
	    height: 38px;
	    border-bottom: 1px solid #ddd;
	}
</style>
</head>

<body>
	<div class="panel panel-info panel-content">
	<div class="panel-heading" style="position: relative;">
			<form id="soform" method="post">
				<table>
					<tr>
						<td class="w80" style="padding-top: 5px">
							<label for="giftName" class="center-block">关键字：</label>
						</td>
						<td class="w150 ">
							<input type="text" class="form-control" name="so_giftName" value="${so_giftName!}" id="so_search" placeholder="礼品名称或者联系人" data-options="">
						</td>
						<td class="w80" style="padding-top: 5px;">
							<label for="companyname" class="center-block">兑换状态：</label>
						</td>
						<td class="w120 ">
							<select class="form-control" name="so_giftState">
							    <option value="" [#if !so_giftState?? || so_giftState=='']selected="selected"[/#if]>全部</option>
								<option value="0" [#if so_giftState?? && so_giftState=='0']selected="selected"[/#if]>未寄出</option>
								<option value="1" [#if so_giftState?? && so_giftState=='1']selected="selected"[/#if]>已寄出</option>
								<option value="2" [#if so_giftState?? && so_giftState=='2']selected="selected"[/#if]>已充值</option>
								<option value="3" [#if so_giftState?? && so_giftState=='3']selected="selected"[/#if]>未充值</option>
							</select>
						</td>
						<td style="padding-left: 10px">
							<div class="input-group">
								<span class="input-group-btn" style="border: 1px solid #ddd;">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
						<td style="display: inline-block;width: 100%;">
                                <button type="button" onclick="plexport('0,3')" class="btn btn-primary btn-sm">导出未处理清单</button>
						</td>
					</tr>
				</table>
		</form>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed" style="margin-bottom: 8px!important;">
			<thead>
				<tr>
					[#--<th width="5%"><input type="checkbox" id="fathCheck"></th>--]
					<th width="5%">序号</th>
					<th width="12%">兑换账户</th>
					<th width="12%">兑换礼品</th>
					<th width="12%">兑换时间</th>
					<th width="9%">联系人</th>
					<th width="10%">联系电话</th>
					<th width="15%">邮寄地址</th>
					<th width="10%">兑换状态</th>
					<th width="10%">操作</th>
				</tr>
			</thead>
			[#list pagination.list as gift]
			<tr>
				[#--<td align="center"><input type="checkbox" class="giftInfoIds" value="${gift.id!}"></td>--]
				<td align="center">${gift_index+1!}</td>
				<td align="center">${gift.email!} ${gift.mobile!}</td>
				<td align="center">${gift.giftName!}</td>
				<td align="center">${(gift.createtime?string("yyyy-MM-dd"))!}</td>
				<td align="center">${gift.contactName!}</td>
				<td align="center">${gift.contactTel!}</td>
				<td align="center">${gift.contactAdd!}</td>
				<td class="ztext" align="center">
						[#if gift.state?? && gift.state==0]未寄出[/#if]
						[#if gift.state?? && gift.state==1]已寄出[/#if]
						[#if gift.state?? && gift.state==2]已充值[/#if]
						[#if gift.state?? && gift.state==3]未充值[/#if]
				</td>
				<td> 
				 [#if gift.state?? && gift.state==0]
				 	<button type="button" class="btn btn-success btn-xs delbtn" onclick="changeGiftState('${gift.id!}','${gift.giftName!}','${gift.contactName!}','${gift.contactAdd!}','${gift.contactTel!}')">寄出</button>
				 [/#if]
				 [#if gift.state?? && gift.state==1]
				 	已寄出
				 [/#if]
				 [#if gift.state?? && gift.state==2]
				 	已充值
				 [/#if]
				 [#if gift.state?? && gift.state==3]
				 	<button type="button" class="btn btn-success btn-xs delbtn">充值</button>
				 [/#if]
				</td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>
	
	<div class="bcksty" id="bckudiv">
		 <div class="title_gift">
			<span class="title_gift_text">邮寄礼品</span>
		 </div>
		 <div style="margin-top: 20px;">
		 	<span class="title_info_font" style="margin-left: 20px;">兑换礼品名称：</span>
		 	<span class="title_info_font" id="giftname"></span>
		 </div>
		 <div style="margin-top: 20px;">
		 	<span class="title_info_font" style="margin-left: 20px;">联系人：</span>
		 	<span class="title_info_font" id="contactName"></span>
		 </div>
		 <div style="margin-top: 20px;">
		 	<span class="title_info_font" style="margin-left: 20px;">邮寄地址：</span>
		 	<span class="title_info_font" id="contactAdd"></span>
		 	<span class="title_info_font" style="margin-left: 20px;">联系电话：</span>
		 	<span class="title_info_font" id="contactTel"></span>
		 </div>
		  <div style="margin-top: 20px;">
		 	<span class="title_info_font" style="margin-left: 20px;">快递公司：</span>
		 	<span class="title_info_font">
		 		<select id="courierCompanyId" name="courierCompanyId" class="form-control" style="width: 200px;display: inline-block;">
		 			[#list deliverys as d]
		 			<option value="${d.id!}">${d.companyName!}</option>
		 			[/#list]
		 		</select>
		 	</span>
		 	<span class="title_info_font" style="margin-left: 20px;">快递单号：</span>
		 	<span class="title_info_font">
		 		<input class="form-control" id="courierNum" name="courierNum" type="text" style="width: 165px;display: inline-block;">
		 	</span>
		 </div>
	</div>
	<form id="mainexport" method="post" action="/gift/plexport.do">
			<input id="exportids" name="state" type="hidden">
	</form>
</body>
</html>
<script type="text/javascript">


</script>